package org.opens.controller;

import org.opens.dao.PersonDao;
import org.opens.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping(value = "/api/person")
public class PersonController {

    @Autowired
    private PersonService personService;

    @GetMapping(value = "/{id:\\d+}")
    public Map<String, Object> queryOne(@PathVariable(value = "id") Integer id) {
        Map<String, Object> result = new HashMap<>();
        result.put("data", personService.findById(id));
        return result;
    }


}
